<?php
include("mysql.php");
if(isset($_GET['ka']) and isset($_GET['sign']) and isset($_GET['ka_time']))
{
$ka=htmlentities($_GET['ka']);
//$sign=sha1(htmlentities($_GET['sign']));
$sign=$_GET['sign'];
$ka_time=htmlentities($_GET['ka_time']);
//echo $ka.'--'.$sign.'--'.$ka_time.'<br>';
if($sign!="hjd124579"){
    echo '非法生成卡密！';
    exit;
}
$mysql="SELECT * 
FROM  `ka` 
WHERE  `kacode` =  '$ka'";
$ret = mysql_query($mysql);
$row=mysql_fetch_array($ret);
if($row){
    echo '此卡已存在！不可重复生成';
    exit;
}

$sql="alter table `ka` AUTO_INCREMENT=1";
mysql_query($sql);  //序列号自动归0

$mysql="INSERT INTO  `ka` (
`id` ,
`kacode` ,
`time` ,
`ka_time`
)
VALUES (
NULL ,  '$ka',  NOW(),  '$ka_time')";
//echo $mysql;
mysql_query($mysql);
echo '卡密生成成功！';
}
else{
    echo '无权访问该文件！';
}
?>